	# Hazel/CMakeLists.txt
	cmake_minimum_required(VERSION 3.20)
	project(Hazel)
	# 设置 C++ 标准
	set(CMAKE_CXX_STANDARD 17)
	set(CMAKE_CXX_STANDARD_REQUIRED ON)

	# 添加 ImGui 源文件
	set(IMGUI_SOURCES
	vendor/imgui/imgui.cpp
	vendor/imgui/imgui_demo.cpp
	vendor/imgui/imgui_draw.cpp
	vendor/imgui/imgui_tables.cpp
	vendor/imgui/imgui_widgets.cpp
	vendor/imgui/backends/imgui_impl_glfw.cpp
	vendor/imgui/backends/imgui_impl_opengl3.cpp
	)
	# 添加源文件
	file(GLOB_RECURSE HAZEL_SOURCES 
	    "src/Hazel/*.cpp"
	    "src/Hazel/*.h"
	    "src/Platform/OpenGL/*.cpp"
		"src/ImGui/*.cpp"
	    "src/ImGui/*.h"
		"src/Platform/Windows/*.cpp"
	    "src/Platform/Windows/*.h"
	)
	# 检查是否找到源文件
	if(NOT HAZEL_SOURCES)
	    message(FATAL_ERROR "No source files found in Hazel project. Please check your directory structure.")
	endif()
	# 创建库
	add_library(Hazel SHARED ${HAZEL_SOURCES})
	# 显式指定链接语言为 C++
	set_target_properties(Hazel PROPERTIES LINKER_LANGUAGE CXX)
	# 包含目录
	target_include_directories(Hazel PUBLIC 
	    ${CMAKE_CURRENT_SOURCE_DIR}/src
	)

	# 创建 ImGui 库
	add_library(ImGui STATIC ${IMGUI_SOURCES})
target_include_directories(ImGui PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}/vendor/imgui
    ${CMAKE_CURRENT_SOURCE_DIR}/vendor/imgui/backends
    ${CMAKE_CURRENT_SOURCE_DIR}/vendor/glfw/include
)
	# 预编译头
	if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/hzpch.h")
	    target_precompile_headers(Hazel PUBLIC
	        ${CMAKE_CURRENT_SOURCE_DIR}/src/hzpch.h
	    )
	endif()
	# 编译器定义
	target_compile_definitions(Hazel PUBLIC
	    HZ_BUILD_DLL
	    HZ_PLATFORM_WINDOWS
	    GLFW_INCLUDE_NONE
	)
	# 处理 Glad
	if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/vendor/glad)
	    add_subdirectory(vendor/glad)
	    target_include_directories(Hazel PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/vendor/glad/include)
	    target_link_libraries(Hazel glad)
	else()
	    message(WARNING "Glad not found, using system OpenGL")
	    find_package(OpenGL REQUIRED)
	    target_include_directories(Hazel PUBLIC ${OPENGL_INCLUDE_DIR})
	    target_link_libraries(Hazel OpenGL::OpenGL)
	endif()
	# 处理 GLFW
	if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/vendor/glfw)
	    add_subdirectory(vendor/glfw)
	    target_link_libraries(Hazel glfw)
	else()
	    find_package(glfw3 REQUIRED)
	    if(glfw3_FOUND)
	        target_include_directories(Hazel PUBLIC ${GLFW3_INCLUDE_DIRS})
	        target_link_libraries(Hazel ${GLFW3_LIBRARIES})
	    else()
	        include(FetchContent)
	        FetchContent_Declare(
	            glfw
	            GIT_REPOSITORY https://github.com/glfw/glfw.git
	            GIT_TAG 3.3.8
	        )
	        FetchContent_MakeAvailable(glfw)
	        target_link_libraries(Hazel glfw)
	    endif()
	endif()
	# 处理 spdlog
	if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/vendor/spdlog)
	    add_subdirectory(vendor/spdlog)
	    target_include_directories(Hazel PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/vendor/spdlog/include)
	else()
	    find_package(spdlog REQUIRED)
	    if(spdlog_FOUND)
	        target_link_libraries(Hazel spdlog::spdlog)
	    else()
	        # 头文件库，直接包含即可
	        target_include_directories(Hazel PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/vendor/spdlog/include)
	    endif()
	endif()
	# Windows 特定设置
	if(WIN32)
	    target_link_libraries(Hazel opengl32)
		# 链接到 Hazel
		target_link_libraries(Hazel ImGui glfw)
	endif()
	# MinGW 特定设置
	if(MINGW)
	    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static -static-libgcc -static-libstdc++")
	endif()
